import request from '@/utils/request.js'

// 人脸注册
// @/api/user.js
export const userPostFaceInfoPicP = (user_id, file) => {
    // ✅ 必须使用 FormData
    const formData = new FormData();
    formData.append('file', file);

    return request({
        method: 'POST',
        url: '/face/info/pic/' + user_id, // 确保 baseURL 已包含 /api
        data: formData
        // 不要加 headers
    });
};

// 人脸注销
export const userDeleteFaceInfoPic = (user_id) => {
    return request ({
        method: 'DELETE',
        url: '/face/info/pic/' + user_id
    })
}

// 人脸识别
export const userPostFaceInfoPicB = (file) => {
    const formData = new FormData()
    formData.append('file', file)

    return request({
        method: 'POST',
        url: '/face/info/pic',
        data: formData,
    })
}

// 获取人脸图片
export const userGetFaceInfoPic = (user_id) => {
    return request({
        method: 'GET',
        url: `/face/fileface-pic/` + user_id ,
        responseType: 'blob' // 关键：获取图片必须加 blob
    })
}

// 人脸检测
export const userPostFaceDetect = (file) => {
    return request ({
        method: 'POST',
        url: '/face/detect',
        data: {
            'file' : file
        }
    })
}